import { ref } from "vue"

// 布尔值的初始化与切换

export function useBoolean(initial = false) {
  const bool = ref(initial);
  const toggle = (target?: any) => {
    bool.value = target === undefined ? !bool.value : Boolean(target)
  }
  const setFalse = () => {
    bool.value = false;
  }
  const setTrue = () => {
    bool.value = true
  }

  return {
    bool, toggle, setFalse, setTrue
  }
}

